<template>
  <div class="count">
    <div class="mui-numbox" data-numbox-min="1" :data-numbox-max="max" :style="myStyle">
      <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
      <input id="test" class="mui-input-numbox" type="number" :value="initcount" ref="num" @change="countChange">
      <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
  </div>
</template>

<script>
import '../lib/js/mui.js'
export default {
  props: ['max', 'initcount', 'goodid', 'size'],
  data () {
    return {
      myStyle: {}
    }
  },
  mounted () {
    if (this.$props.size === 'small') {
      this.myStyle = { width: '130px', height: '25px', margin: '0 10px 0 10px' }
    }
  },
  created () {

  },
  methods: {
    countChange () {
      const count = parseInt(this.$refs.num.value)
      this.$emit('count', { goodid: this.goodid, count: count })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
